package com.yxym.codeblock;
public class CodeBlockDetail02 {
    public static void main(String[] args) {
        B b  = new B();
        B b1 =new B();
        C c = new C();
        C c1 = new C();
        D d =new D();
    }
}

class B{
    static {//静态代码块
        System.out.println("A 静态代码块01");
    }
    private static String string = getString();//静态属性初始化
    public static String getString(){
        System.out.println("getString被调用...");
        return "小白与小青";
    }
    static {
        System.out.println("A 静态代码块02");
    }
    private static int n1 = getN1();
    public static int getN1(){
        System.out.println("getN1被调用...");
        return 10;
    }
    private int n2 = getN2();
    public int getN2(){
        System.out.println("getN2被调用...");
        return 100;
    }
    {
        System.out.println("A的普通代码块...");
    }
    //无参构造器
    public B(){
        System.out.println("B的无参构造器被调用...");
    }
}

class C{
    public C(){
        //1.super()
        //2.调用本类的普通代码块
        System.out.println("C()构造器被调用...");
    }
    {
        System.out.println("C的普通代码块...");
    }
}

class D{
    {
        System.out.println("D的普通代码块...");
    }
    public D(){
        //1.super()
        //2.调用本类的普通代码块
        System.out.println("D()构造器被调用...");
    }
}